//
//  TMCourseSaleCell.m
//  国学商家管理
//
//  Created by Tao Li on 2018/7/5.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "TMCourseSaleCell.h"
#import "TMShopCourseModel.h"
#import "TMCourseTypeModel.h"
#import "TMMyCourseModel.h"
@implementation TMCourseSaleCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.contentView.layer.borderWidth = 1.0f;
    self.contentView.layer.borderColor = [UIColor hx_colorWithHexRGBAString:@"#EEEEEE"].CGColor;
    self.courseImage.contentMode = UIViewContentModeScaleAspectFill;
    self.courseImage.clipsToBounds = YES;
}
- (void)setIsOrder:(BOOL)isOrder{
    _isOrder = isOrder;
    if (_isOrder == YES) {
        self.courseLabel.textAlignment = NSTextAlignmentCenter;
        self.teacherLabel.textAlignment = NSTextAlignmentCenter;
        self.haveSaetLabel.textAlignment = NSTextAlignmentCenter;
        self.courseType.textAlignment = NSTextAlignmentCenter;
        self.priceLabel.textAlignment = NSTextAlignmentCenter;
    }else{
        self.courseLabel.textAlignment = NSTextAlignmentLeft;
        self.teacherLabel.textAlignment = NSTextAlignmentLeft;
        self.haveSaetLabel.textAlignment = NSTextAlignmentLeft;
        self.courseType.textAlignment = NSTextAlignmentLeft;
        self.priceLabel.textAlignment = NSTextAlignmentLeft;
    }
}
-(void)setModel:(TMShopCourseModel *)model{
    _model = model;
    if (model.pic.count>0) {
        [self.courseImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithBaseUrl:model.pic[0]]] placeholderImage:kPlaceholder];
    }else{
    //[self.courseImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithBaseUrl:model.pic[0]]] placeholderImage:kPlaceholder];
    }
    self.courseLabel.text = model.name;
    self.teacherLabel.text = [NSString stringWithFormat:@"任课教师:%@", model.tea_name];
    self.haveSaetLabel.text = [NSString stringWithFormat:@"剩余空位:%ld", model.surplus];
    self.courseType.text = [NSString stringWithFormat:@"课程分类:%@", model.type_name];
    self.priceLabel.text = [NSString stringWithFormat:@"价格:¥%.02f", model.price];
}

-(void)setBoutiqueModel:(TMCourseTypeModel *)boutiqueModel{
    _boutiqueModel = boutiqueModel;
    [self.courseImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithBaseUrl:boutiqueModel.pic[0]]] placeholderImage:kPlaceholder];
    self.courseLabel.text = boutiqueModel.name;
    self.teacherLabel.text = [NSString stringWithFormat:@"任课教师:%@", boutiqueModel.teacher];
    self.haveSaetLabel.text = [NSString stringWithFormat:@"剩余空位:%ld", boutiqueModel.num];
    self.teacherLabel.text = [NSString stringWithFormat:@"课程分类:%@", boutiqueModel.type];
    self.priceLabel.text = [NSString stringWithFormat:@"价格:¥%.02f", boutiqueModel.price];
}
- (void)setCourseModel:(TMMyCourseModel *)courseModel{
    _courseModel = courseModel;
    if (courseModel.photo.count>0) {
        [self.courseImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithBaseUrl:courseModel.photo[0]]] placeholderImage:kPlaceholder];
    }
    self.courseLabel.text = courseModel.course;
    self.teacherLabel.text = [NSString stringWithFormat:@"任课教师:%@", courseModel.teacher];
    self.haveSaetLabel.text = [NSString stringWithFormat:@"剩余空位:%ld", courseModel.surplus];
    self.teacherLabel.text = [NSString stringWithFormat:@"课程分类:%@", courseModel.type];
    self.priceLabel.text = [NSString stringWithFormat:@"价格:¥%.02f", courseModel.price];
}
@end
